import PostList from '@/components/post/post-list';
import { getAllPosts } from '@/db/queries'
import type { Metadata } from 'next'

export const metadata: Metadata = {
  title: 'Next.js 15 Blog',
  description: 'A blog created by Next.js 15'
}

export default async function Page() {

  const posts = await getAllPosts()

  return <main className='py-10'>
    <div className='max-w-7xl mx-auto px-4'>
      {
        posts.length === 0 ?
          <div className='text-center py-10'>
            <h2 className='text-xl font-medium'>No posts found</h2>
          </div>
          : <PostList posts={posts} />
      }
    </div>
  </main>
}
